﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GIMP
{
    public partial class Histograma : Form
    {
        Bitmap imagem = null;
        PI PI = new PI();
        ComponentResourceManager resources = new ComponentResourceManager(typeof(Histograma));

        public Histograma(Bitmap imagem)
        {
            InitializeComponent();
            this.imagem = imagem;
            this.comboBox1.SelectedIndex = 0;
        }

        public string SelectedChannel
        {
            get
            {
                return this.comboBox1.SelectedText;
            }
        }

        private void MudaCorHistograma(object sender, EventArgs e)
        {
            if (this.comboBox1.Text.Equals("Red"))
            {
                this.histogram1.Values = PI.Histograma(this.imagem, 'R');
                this.histogram1.Color = Color.FromArgb(255, 0, 0);
                this.pictureBox1.BorderStyle = BorderStyle.FixedSingle;
                this.pictureBox1.Image = Properties.Resources.bar_histoR;
            }
            else
            {
                if (this.comboBox1.Text.Equals("Green"))
                {
                    this.histogram1.Values = PI.Histograma(this.imagem, 'G');
                    this.histogram1.Color = Color.FromArgb(0, 255, 0);
                    this.pictureBox1.BorderStyle = BorderStyle.FixedSingle;
                    this.pictureBox1.Image = Properties.Resources.bar_histoG;
                }
                else
                {
                    if (this.comboBox1.Text.Equals("Blue"))
                    {
                        this.histogram1.Values = PI.Histograma(this.imagem, 'B');
                        this.histogram1.Color = Color.FromArgb(0, 0, 255);
                        this.pictureBox1.BorderStyle = BorderStyle.FixedSingle;
                        this.pictureBox1.Image = Properties.Resources.bar_histoB;
                    }
                    else
                    {
                        this.histogram1.Values = PI.Histograma(this.imagem, 'X');
                        this.histogram1.Color = Color.FromArgb(0, 0, 0);
                        this.pictureBox1.BorderStyle = BorderStyle.FixedSingle;
                        this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
                    }
                }
            }
        }
    }
}
